package com.hc.server.user.controller;

import com.hc.server.common.constant.MQConstant;
import com.hc.server.common.domain.vo.response.ApiResult;
import com.hc.server.user.domain.dto.UIDLoginMessageDTO;
import com.hc.server.user.service.LoginService;
import com.hc.transaction.service.MQProducer;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by wdj on 2024/10/19
 */

@RestController
@Slf4j
@Api(tags = "登录相关接口")
public class LoginController {

    @Autowired
    private LoginService loginService;
    @Autowired
    private MQProducer mqProducer;

    @PostMapping("/uidLogin")
    @ApiOperation("用户登录")
    public ApiResult<String> uidLogin(Long uid){
        String token = loginService.login(uid);
        mqProducer.sendMsg(MQConstant.LOGIN_MSG_TOPIC_UID, new UIDLoginMessageDTO(uid, 200));
        return ApiResult.success(token);
    }
}
